window.onload=function (){
    //导航栏下拉
    var dropdown=document.getElementById("dropdown")
    var dropdownLi=dropdown.getElementsByTagName("li")

    //循环遍历
    for (var i = 0; i <dropdownLi.length; i++) {
        if(i==1){
            continue;
        }//当i=1时，跳过
        dropdownLi[i].onmouseover = function () {
            this.classList.add("show")
        }
        dropdownLi[i].onmouseout = function () {
            this.classList.remove("show")
        }
    }
    //分类拉出
    var dropright=document.getElementById("dropright")
    var droprightLi=dropright.getElementsByTagName("li")

    //循环遍历
    for (var i = 0; i < droprightLi.length; i++) {
        droprightLi[i].onmouseover=function (){
            this.classList.add("show")
        }
        droprightLi[i].onmouseout=function (){
            this.classList.remove("show")
        }
    }
    //轮播图js
    var carousel=document.getElementById("carousel")
    var left=document.getElementById("left")
    var right=document.getElementById("right")
    var image=document.getElementById("image")
    var numList=document.getElementById("number").getElementsByTagName("li")
    var links=document.getElementById("links")

    //初始化准备
    var add=1;
    var arr=['http://www.baidu.com','http://www.taobao.com','http://www.bilibili.com','http://www.baidu.com','http://www.baidu.com','http://www.baidu.com']
    //添加图片
    image.src="./images/ad01.jpg"
    numList[0].style.background="#fff";
    links.href=arr[0];
    //鼠标移入显示左右箭头
     carousel.onmouseover=function (){
         left.style.display="block"
         right.style.display="block"
         clearInterval(lun);//鼠标点上去时 定时停止
     }
    //鼠标移除消失左右箭头
    carousel.onmouseout=function (){
         left.style.display="none"
        right.style.display="none"
        carouselLb();//鼠标离开 定时继续
     }
     //轮播切换图片
    function  carouselLb(){
         lun=setInterval(function (){
             add=add+1;
             if(add>6){
                 add=1;
             }
        image.src="./images/ad0"+add+".jpg";
        var x=add-1;
        links.href=arr[add-1];//点击跳转网址
        for (var i = 0; i < numList.length; i++) {

             numList[i].style.background="#3e3e3e";
                 if(x==i){
                     numList[i].style.background="#fff";
                 }
             }
        },3000)

    }
    carouselLb()
    //点击左右箭头切换图片
    left.onclick=function (){
        add=add-1;
        if(add<1){
            add=6;
        }
        image.src= "./images/ad0" +add+".jpg";

        var x=add-1;
        links.href=arr[add-1];//点击跳转网址
        for (var i = 0; i < numList.length; i++) {

            numList[i].style.background="#3e3e3e";
            if(x==i){
                numList[i].style.background="#fff";
            }
        }
    }
    right.onclick=function (){
        add=add+1;
        if(add>6){
            add=1;
        }
        image.src="./images/ad0" +add+".jpg";
        
        var x=add-1;
        links.href=arr[add-1];//点击跳转网址
        for (var i = 0; i < numList.length; i++) {

            numList[i].style.background="#3e3e3e";
            if(x==i){
                numList[i].style.background="#fff";
            }
        }
    }
    //鼠标点击下面的小白点也能切换图片
    for (var i = 0; i < numList.length; i++) {
        numList[i].onmouseover=function(){
            add=this.innerHTML
            image.src="./images/ad0" +add+".jpg";
            links.href=arr[add-1];//点击跳转网址
            var x=add-1;
            for (var i = 0; i < numList.length; i++) {

                numList[i].style.background="#3e3e3e";
                if(x==i){
                    numList[i].style.background="#fff";
                }
            }
        }

    }
    //猫眼电影的效果
    //猫眼电影的节点
    var movieShow=document.getElementById("movie-show")
    var movieLeft=document.getElementById("movieleft")
    var movieRight=document.getElementById("movieright")
    //
    var movieTab=document.getElementById("movie-tab")
    var movieTabLi=movieTab.getElementsByTagName("li")
    var movieShowClass=movieShow.getElementsByClassName("moviehot")
    var movieTabTriangle=movieTab.getElementsByClassName("triangle")

    var nowhot=document.getElementById("nowhot")
    var quick=document.getElementById("quick")

    //鼠标移入显示左右箭头
    movieShow.onmouseover=function (){
        movieLeft.style.display="block"
        movieRight.style.display="block"
    }
    movieShow.onmouseout=function (){
        movieLeft.style.display="none"
        movieRight.style.display="none"
    }
    //鼠标移入li节点上面显示对应的区域
    movieTabLi[1].onclick=function (){

        movieShowClass[0].style.display="block"
        movieShowClass[1].style.display="none"
        movieTabTriangle[0].style.display="block"
        movieTabTriangle[1].style.display="none"
    }

    movieTabLi[2].onclick=function (){
         movieShowClass[1].style.display="block"
         movieShowClass[0].style.display="none"
         movieTabTriangle[1].style.display="block"
         movieTabTriangle[0].style.display="none"
    }


    //点击左右箭头进行滑动
    var num=0;
    movieRight.onclick=function(){
      if(nowhot.style.display=="block"){
          movielun=setInterval(function (){
              num-=30;  //20毫秒向左移动30
              nowhot.style.left=num+"px"
              //console.log(num)
              if(num<=-1200){
                  clearInterval(movielun); //滚动1200，关闭轮播
                  movieRight.disabled="disabled"; //禁用右点击按钮
                  movieRight.innerHTML="X";
              }
          },20)
      }else{
          movielun=setInterval(function (){
              num-=30;
              quick.style.left=num+"px"
             // console.log(num)
              if(num<=-1200){
                  clearInterval(movielun)
                  movieRight.disabled="disabled";
                  movieRight.innerHTML="x";
              }
          },20)
      }


      }
    movieLeft.onclick=function(){
        if(nowhot.style.display=="block"){
            movielun=setInterval(function (){
                num+=20;
                nowhot.style.left=num+"px"
                if(num>=0){
                    clearInterval(movielun)
                    movieRight.disabled=false;
                    movieLeft.disabled="disabled"
                    movieRight.innerHTML="&gt"
                    movieLeft.innerHTML="X"
                }
            },20)
        }else {
            movielun=setInterval(function (){
                num+=30;
                quick.style.left=num+"px"
                // console.log(num)
                if(num>=0){
                    clearInterval(movielun)
                    movieRight.disabled=false;
                    movieLeft.disabled="disabled";
                    movieRight.innerHTML="X";
                    movieLeft.innerHTML="&lt";
                }
            },20)
        }


    }



}